#include<iostream>
#include<unistd.h>
#include <vector>
#include <sys/types.h>
using namespace std;

const int num  = 10;

void SubRun()
{
  while(1)
  {
     cout << "I am sun process,pid:" << getpid() << ",ppid: " << getppid() << std::endl;
     sleep(1);
  }

}

int main()
{
 vector<pid_t> allchild;
 for(int i = 0 ; i < num;i++)
 {
   pid_t id = fork();
   if(id == 0)
   {
     //sub process  
     SubRun();
   }
   //parent process
   allchild.push_back(id);
 }
 //parent
 cout << "my child:";
 for(auto child:allchild)
 {
   cout << child << " " ;
 }
 cout << endl;
 while(1)
 {
   cout << "I am parent process,pid:" << getpid() << endl;
   sleep(1);
 }
  return 0;
}

